﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using com.tiyma.common;
using com.tiyma.components;
using com.tiyma.model;
namespace com.tiyma.web.User
{
    public partial class BookCase : BasePage
    {
        BookManager m_book_mgr = new BookManager();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Token == null)
                RedirectErrorPage();
            if (!IsPostBack)
            {
                BindBookList();
            }

        

                lblScript.Text = string.Format("<script>ChangeTab('{0}');</script>",string.IsNullOrEmpty( Request["type"])?1:2);
           
        }

        private void BindBookList()
        {
            try
            {
                List<BookInfo> t_list = m_book_mgr.GetUserBook(Token.UserId);

                if (t_list != null && t_list.Count > 0)
                {
                    rptBookCase.DataSource = t_list;
                    rptBookCase.DataBind();
                    lblBookCaseCount.Text = t_list.Count.ToString();
                }

                List<ChapterInfo> t_chapter_list =CookieManager.GetCurReadList();

                if (t_chapter_list != null && t_chapter_list.Count > 0)
                {
                    rptCurRead.DataSource = t_chapter_list;
                    rptCurRead.DataBind();
                    lblCurReadCount.Text = t_chapter_list.Count.ToString();
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error("绑定书架信息失败" + ex.ToString());
                RedirectErrorPage();
            }
        }

       
    }
}
